package cn.zhf.shop.controller;

import cn.zhf.shop.entity.AgentApplication;
import cn.zhf.shop.entity.Bankcard;
import cn.zhf.shop.entity.Message;
import cn.zhf.shop.service.AgentApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@RequestMapping("/api/AgentApplication")
@Api(tags = "代理人申请提升等级")
public class AgentApplicationController {
    @Resource
    private AgentApplicationService agentApplicationService;

    @PostMapping("/")
    @ApiOperation(value = "提交申请")
    public Message insert(AgentApplication agentApplication){
        return agentApplicationService.insertSelective(agentApplication);
    }

    @DeleteMapping("/")
    @ApiOperation(value = "根据申请id删除申请")
    public Message deleteById(int agentApplicationId){
        return agentApplicationService.deleteByPrimaryKey(agentApplicationId);
    }

    @PutMapping("/status")
    @ApiOperation(value = "根据id修改申请状态")
    public Message updateStatusById(Integer updatedAgentApplicationStatus, Integer agentApplicationId){
        return agentApplicationService.updateAgentApplicationStatusByAgentApplicationId(updatedAgentApplicationStatus, agentApplicationId);
    }

    @PutMapping("/id")
    @ApiOperation(value = "修改申请")
    public Message update(AgentApplication agentApplication){
        agentApplication.setAgentApplicationPostTime(new Date());
        return agentApplicationService.updateByPrimaryKeySelective(agentApplication);
    }

    @GetMapping("/agentApplicationId")
    @ApiOperation(value = "根据申请id查看申请")
    public Message selectById(Integer agentApplicationId){
        return agentApplicationService.selectByPrimaryKey(agentApplicationId);
    }

    @GetMapping("/userId")
    @ApiOperation(value = "根据userid获得申请记录")
    public Message selectByUserId(Integer userId){
        return agentApplicationService.selectByAgentApplicationUserId(userId);
    }

    @GetMapping("/all")
    @ApiOperation(value = "获得所有申请记录")
    public Message selectAll(){
        return agentApplicationService.selectAll();
    }

}
